import type {BasicColumn, FormSchema} from '@/components/Table'
import {useRender} from '@/components/Table'
import {DICT_TYPE, getDictOptions} from "@/utils/dict";
// import {DICT_TYPE, getDictOptions} from "@/utils/dict";

export const columns: BasicColumn[] = [
  {
    title: '编号',
    dataIndex: 'id',
    width: 160
  },
  {
    title: '接入应用id',
    dataIndex: 'appId',
    width: 160
  },
  {
    title: '接入应用密钥',
    dataIndex: 'appSecret',
    width: 160
  },
  {
    title: '渠道名称',
    dataIndex: 'name',
    width: 160
  },
  {
    title: '回调地址',
    dataIndex: 'callbackUrl',
    width: 160
  },
  {
    title: '授权业务id',
    dataIndex: 'bizId',
    width: 160
  },
  {
    title: '扣量百分比',
    dataIndex: 'reduceRatio',
    width: 160
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 160
  },
  {
    title: '渠道配置',
    dataIndex: 'configData',
    width: 160
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
    customRender: ({text}) => {
      return useRender.renderDate(text)
    }
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    label: '接入应用id',
    field: 'appId',
    component: 'Input',
    colProps: {span: 8}
  },
  {
    label: '接入应用密钥',
    field: 'appSecret',
    component: 'Input',
    colProps: {span: 8}
  },
  {
    label: '渠道名称',
    field: 'name',
    component: 'Input',
    colProps: {span: 8}
  },
  {
    label: '授权业务id',
    field: 'bizId',
    component: 'Input',
    colProps: {span: 8}
  },
  {
    label: '状态',
    field: 'status',
    component: 'Input',
    componentProps: {
      options: [],
    },
    colProps: {span: 8}
  },
  {
    label: '创建时间',
    field: 'createTime',
    component: 'RangePicker',
    colProps: {span: 8}
  },
]

export const createFormSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input'
  },
  {
    label: '渠道名称',
    field: 'name',
    required: true,
    component: 'Input'
  },
  {
    label: '回调地址',
    field: 'callbackUrl',
    required: true,
    component: 'Input'
  },
  {
    label: '回调方法',
    field: 'callbackMethod',
    required: true,
    component: 'RadioButtonGroup',
    componentProps: {
      options: [
        {label: 'GET', value: 'GET', key: 'GET'},
        {label: 'POST', value: 'POST', key: 'POST'},
      ],
    }
  },
  {
    label: '授权业务',
    field: 'bizId',
    required: true,
    // component: 'Input',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DICT_TYPE.bizEnum, 'string'),
    },
  },
  {
    label: '扣量百分比',
    field: 'reduceRatio',
    required: true,
    component: 'InputNumber'
  },
  {
    label: '授权用户',
    field: 'authUserIds',
    required: false,
    component: 'Select',
    componentProps: {
      options: [
        {label: 'orderAdmin', value: '131', key: '131'},
        {label: 'bizAdmin', value: '130', key: '130'},
        {label: 'liuAdmin', value: '132', key: '132'},
      ],
      mode: "multiple",
    }
  },
  {
    label: '状态',
    field: 'status',
    required: true,
    component: 'RadioButtonGroup',
    componentProps: {
      options: [
        {label: '启用', value: 'ENABLE', key: 'ENABLE'},
        {label: '禁用', value: 'DISABLE', key: 'DISABLE'},
      ],
    }
  },
  {
    label: '渠道配置',
    field: 'configData',
    component: 'Input'
  },
]

export const updateFormSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input'
  },
  {
    label: '接入应用id',
    field: 'appId',
    required: true,
    dynamicDisabled: true,
    component: 'Input'
  },
  {
    label: '接入应用密钥',
    field: 'appSecret',
    required: true,
    dynamicDisabled: true,
    component: 'Input'
  },
  {
    label: '渠道名称',
    field: 'name',
    required: true,
    component: 'Input'
  },
  {
    label: '回调地址',
    field: 'callbackUrl',
    required: true,
    component: 'Input'
  },
  {
    label: '回调方法',
    field: 'callbackMethod',
    required: true,
    component: 'RadioButtonGroup',
    componentProps: {
      options: [
        {label: 'GET', value: 'GET', key: 'GET'},
        {label: 'POST', value: 'POST', key: 'POST'},
      ],
    }
  },
  {
    label: '授权业务id',
    field: 'bizId',
    required: true,
    // component: 'Input'
    component: 'Select',
    componentProps: {
      options: getDictOptions(DICT_TYPE.bizEnum, 'string'),
    },
  },
  {
    label: '扣量百分比',
    field: 'reduceRatio',
    required: true,
    component: 'InputNumber',
  },
  {
    label: '授权用户',
    field: 'authUserIds',
    required: false,
    component: 'Select',
    componentProps: {
      options: [
        {label: 'orderAdmin', value: '131', key: '131'},
        {label: 'bizAdmin', value: '130', key: '130'},
        {label: 'liuAdmin', value: '132', key: '132'},
      ],
      mode: "multiple",
    }
  },
  {
    label: '状态',
    field: 'status',
    required: true,
    component: 'RadioButtonGroup',
    componentProps: {
      options: [
        {label: '启用', value: 'ENABLE', key: 'ENABLE'},
        {label: '禁用', value: 'DISABLE', key: 'DISABLE'},
      ],
    }
  },
  {
    label: '渠道配置',
    field: 'configData',
    component: 'Input'
  },
]
